<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新增资质项</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/buildUnit/common.css">
    <link rel="stylesheet" href="/statics/layui/font/font.css" media="all"/>
    <style type="text/css">
        html, body {
            height: 100%;
            overflow-y: auto;
        }
        .hide{
            display: none;
        }
    </style>
</head>
<body>
<form class="layui-form layui-form-pane" id="example" lay-filter="formData">
    <div class="layui-fluid">
        <table class="layui-table v-table">
            <tbody>
            <tr>
                <td class="th8 required">资质序列</td>
                <td colspan="3">
                    <input type="hidden" name="id" class="formData">
                    <select name="gradeType" class="formData" id="gradeType" lay-verify="isEmpty" lay-filter="gradeType">
                        <option>请选择</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="th8 required">资质行(专)业</td>
                <td colspan="3">
                    <select name="aptitudeIndustry" class="formData" id="aptitudeIndustry" lay-filter="aptitudeIndustry"
                            lay-verify="isEmpty">
                        <option value=""></option>
                    </select>
                </td>
            </tr>
            <tr class="zizhiSpecialtyBox hide">
                <td class="th8 required">资质专业</td>
                <td>
                    <select name="aptitudeSpeciality" class="formData" id="aptitudeSpeciality" lay-verify="isEmpty">
                        <option value=""></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="th8 required">就位日期</td>
                <td>
                    <input type="text" class="layui-input time formData" placeholder="请选择" name="positionDate"
                           lay-verify="isEmpty"
                           id="positionDate" readonly/>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <button lay-submit lay-filter="submit" style="display: none;" id="submit" class="demo1">提交</button>
</form>
<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<!--<script type="text/javascript" src="../../../statics/js/sys/editDict.js"  charset="utf-8"></script>-->
<script>
    layui.use(['form', 'sessionFun', 'configure', 'configureCom', 'laydate'], function () {
        window.$ = layui.$;
        var form = layui.form;
        var configure = layui.configure;
        var configureCom = layui.configureCom;
        var laydate = layui.laydate;
        var sessionFun = layui.sessionFun;
        //执行一个laydate实例
        $('.time').each(function (index, item) {
            laydate.render({
                elem: item, //指定元素
                format: 'yyyy-MM-dd'
            });
        });
        var listData = sessionFun.get(configure.SESSION_ZIZHIITEM_LIST_DATA);
        if (listData) {
            if(listData.aptitudeIndustry==3){//资质行业（专业）是否为市政
                $('.zizhiSpecialtyBox').removeClass('hide');
            }
            if(listData.gradeType==1){//资质序列为一类
                configureCom.selectDataFun(configure.APTITUDE_INDUSTRY, listData.aptitudeIndustry, '#aptitudeIndustry');//资质行业（专业）一类
            }
            if(listData.gradeType==2){//资质序列为二类
                configureCom.selectDataFun(configure.APTITUDE_INDUSTRY2, listData.aptitudeIndustry2, '#aptitudeIndustry');//资质行业（专业）二类
            }
            configureCom.selectDataFun(configure.APTITUDE_SEQUENCE, listData.gradeType, '#gradeType');//资质序列
            configureCom.selectDataFun(configure.APTITUDE_SPECIALITY, listData.aptitudeSpeciality, '#aptitudeSpeciality');//资质专业
        } else {
            configureCom.selectDataFun(configure.APTITUDE_SEQUENCE, '', '#gradeType');//资质序列
            configureCom.selectDataFun(configure.APTITUDE_SPECIALITY, '', '#aptitudeSpeciality');//资质专业
        }
        form.val('formData', listData);
        form.render();
        form.on('select(gradeType)', function (obj) {
            console.log(obj);
            var value = obj.value;
            if (value == 1) {
                configureCom.selectDataFun(configure.APTITUDE_INDUSTRY, '', '#aptitudeIndustry');//资质行业（专业）(一类专业)
            }
            if (value == 2) {
                configureCom.selectDataFun(configure.APTITUDE_INDUSTRY2, '', '#aptitudeIndustry');//资质行业（专业）(二类专业)
            }

        });
        //资质行(专)业--市政是否显示专业
        form.on('select(aptitudeIndustry)', function (obj) {
            console.log(obj);
            var value = obj.value;
            if (value == 3) {
                $('.zizhiSpecialtyBox').removeClass('hide');
            }else{
                $('.zizhiSpecialtyBox').addClass('hide');
            }
        });
        form.on('submit(submit)', function (data) {
            return false;
        });
    });

    function getData() {
        return new Promise(function (resolve, reject) {
            if (!window.formVerifyFun()) {
                return false;
            }
            var data = {};
            $('.formData').each(function (index, item) {
                if (!($(item).closest('tr').hasClass('hide'))) {
                    var key = $(item).attr('name');
                    data[key] = $(item).val();
                }
            });
            resolve({result: data});
        })
    }
</script>
</body>
</html>
